function t(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var i = t(require("../../../utils/api2")), e = t(require("../../../utils/api")), a = t(require("../../../utils/util")), s = require("../../../public/pages/signin-page/checkIfNeedSignin"), r = require("../../../components/navigation-bar/mixin");

Page({
    data: {
        avatar: "",
        name: "",
        mode: "view",
        gather: {}
    },
    onLoad: function(t) {
        this.setData({
            sid: t.sid
        }), this.getUserInfo(), r.navigationMixIn.addTo(this);
    },
    onShow: function() {
        this.refresh();
    },
    initData: function(t) {
        this.loadSiteInfo(t), this.loadSettings(t.sid), this.loadProductOrderCount(t.sid), 
        this.loadServiceOrderCount(t.sid), this.checkIfNeedVerifyMobile(), this.loadVipInfo(t.sid);
    },
    refresh: function() {
        this.initData(this.__query);
    },
    getUserInfo: function() {
        var t = getApp().globalData, i = t.tokens, e = t.card;
        this.setUserInfo({
            nickName: e.realname || i.realname,
            avatarUrl: e.avatar || i.avatar
        });
    },
    setUserInfo: function(t) {
        this.setData({
            avatar: t.avatarUrl,
            name: a.default.sliceByByte(a.default.filterEmoji(t.nickName), 8)
        });
    },
    loadSiteInfo: function(t) {
        var e = this, s = t.sid, r = t.navid;
        i.default.site.site.view({
            data: {
                sid: s
            }
        }).then(function(t) {
            var i = a.default.formatSidebarNavUrl(t.navlist, r);
            e.initNavigation(t, i), e.setData({
                mchid: t.mchid
            });
        });
    },
    loadSettings: function(t) {
        var e = this, a = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "view";
        i.default.site.usercenter.lists({
            data: {
                sid: t,
                op: a
            },
            desc: "加载设置"
        }).then(function(i) {
            var a = {};
            i.forEach(function(t) {
                a[t.node] = t;
            }), e.setData({
                gather: a
            }), a.distribute && e.loadDistributeInfo(t);
        });
    },
    loadProductOrderCount: function(t) {
        var e = this;
        i.default.site.productorder.getmyordercount({
            data: {
                sid: t
            }
        }).then(function(t) {
            e.setData({
                productOrderCount: t
            });
        });
    },
    loadServiceOrderCount: function(t) {
        var e = this;
        i.default.site.servicesorder.getmyordercount({
            data: {
                sid: t
            }
        }).then(function(t) {
            e.setData({
                servicesOrderCount: t
            });
        });
    },
    checkIfNeedVerifyMobile: function() {
        1 != +getApp().globalData.tokens.isverifymobile && this.setData({
            needVerifyMobile: !0
        });
    },
    loadVipInfo: function(t) {
        var e = this;
        i.default.site.member.view({
            data: {
                sid: t
            }
        }).then(function(t) {
            e.setData({
                member: t.member,
                isShowMemberManage: "thirdparty" === getApp().globalData.app && t.ismanager
            });
        });
    },
    loadDistributeInfo: function(t) {
        var i = this;
        return e.default.site.distribute.viewmember({
            data: {
                sid: t
            },
            desc: "加载中"
        }).then(function(t) {
            var e = t.data, a = e.code, s = e.data.member;
            0 == +a && i.setData({
                distribute: s
            });
        });
    },
    bindMobile: function() {
        this.setData({
            authMobileShow: !0
        });
    },
    verifySuccess: function() {
        this.setData({
            needVerifyMobile: !1
        });
    },
    orderlist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/profile/orderlist/orderlist?sid=" + t);
    },
    servicelist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/profile/reservationlist/reservationlist?sid=" + t);
    },
    grouponlist: function() {
        var t = this.data.sid, i = this.data.sidebar.site.name;
        (0, s.askForSignin)() || this.$route("/pages/profile/grouponlist/grouponlist?sid=" + t + "&name=" + i);
    },
    paybilllist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/profile/payment-record/payment-record?sid=" + t + "&origin=user");
    },
    conpouslist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/profile/coupon/list/list?sid=" + t);
    },
    bargainlist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/common/bargaining/mylist/mylist?sid=" + t);
    },
    cartlist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/common/shopping-cart/shopping-cart?sid=" + t + "&app=" + getApp().globalData.app + "&mchid=" + this.data.mchid);
    },
    addresslist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/common/address/list/list?sid=" + t + "&app=" + getApp().globalData.app + "&origin=profile");
    },
    lotterylist: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || this.$route("/pages/common/raffle/prize-list/prize-list?sid=" + t);
    },
    activitylist: function() {
        var t = this.data.sid;
        this.$route("/pages/common/activity/list/list?sid=" + t);
    },
    distributeCenter: function() {
        var t = this.data.sid;
        (0, s.askForSignin)() || (this.data.distribute && 1 == +this.data.distribute.status ? this.$route("/pages/profile/distribute/index/index?sid=" + t) : this.data.distribute && 0 == +this.data.distribute.status ? this.$route("/pages/profile/distribute/apply/apply?sid=" + t + "&status=success") : this.data.distribute && 2 == +this.data.distribute.status ? this.$route("/pages/profile/distribute/apply/apply?sid=" + t + "&status=fail") : this.data.distribute || this.$route("/pages/profile/distribute/apply/apply?sid=" + t));
    },
    gotoOrderStatus: function(t) {
        var i = t.currentTarget.dataset.type;
        (0, s.askForSignin)() || this.$route("/pages/profile/orderlist/orderlist?sid=" + this.data.sid + "&status=" + i);
    },
    gotoServiceStatus: function(t) {
        var i = t.currentTarget.dataset.type;
        (0, s.askForSignin)() || this.$route("/pages/profile/reservationlist/reservationlist?sid=" + this.data.sid + "&status=" + i);
    },
    onPullDownRefresh: function() {
        this.refresh(), setTimeout(wx.stopPullDownRefresh, 1e3);
    }
});